import fetch from 'utils/fetch';

export function page(query) {
  return fetch({
    url: '/api/shop/goods/goods/admin/list',
    method: 'get',
    params: query
  });
}

export function addObj(obj) {
  return fetch({
    url: '/api/shop/goods/goods/admin/addGoods',
    method: 'post',
    data: obj
  });
}

export function getObj(id) {
  return fetch({
    url: '/api/shop/goods/goods/admin/getGoodsInfo/' + id,
    method: 'get'
  })
}

export function delObj(id) {
  return fetch({
    url: '/api/shop/goods/goods/admin/deleteGoods/' + id,
    method: 'delete'
  })
}

export function putObj(id, obj) {
  return fetch({
    url: '/api/shop/goods/goods/admin/updateGoods/' + id,
    method: 'put',
    data: obj
  })
}

export function GetTopCategory() { //查询一级分类
  return fetch({
    url: '/api/shop/goods/category/admin/getTopCategory',
    method: 'get'
  })
}

export function GetSecondLevel(val) { //根据一级分类查询二级分类
  return fetch({
    url: '/api/shop/goods/category/admin/getSecondLevel',
    method: 'get',
    params: val
  })
}

export function getSelectByshops(id) { //根据店铺查询本店铺的商品
  return fetch({
    url: '/api/shop/goods/goods/admin/getSelectByShopsB/' + id,
    method: 'get'
  })
}

export function promotionPage(query) {
  return fetch({
    url: '/api/shop/goods/promotion/admin/promotionList',
    method: 'get',
    params: query
  })
}

export function promotionTerm(query) {
  return fetch({
    url: '/api/shop/goods/promotion/admin/promotionTermLike',
    method: 'get',
    params: query
  })
}

export function updatePromotion(prom) {
  return fetch({
    url: '/api/shop/goods/promotion/admin/updatePromotion',
    method: 'put',
    data: prom
  })
}

export function getByModelList(id) {
  return fetch({
    url: '/api/shop/goods/goods/admin/getByModelList/'+id,
    method: 'get'
  })
}

export function addGoodsModel(pojo) {
  return fetch({
    url: '/api/shop/goods/goods/admin/addGoodsModel',
    method: 'get',
    params: pojo
  })
}

export function selectByGoodsModelVal(val){
  return fetch({
    url:'/api/shop/goods/goods/admin/selectByGoodsModelVal',
    method:'get',
    params:val
  })
}

export function addGoodsModelVal(pojo){
  return fetch({
    url:'/api/shop/goods/goods/admin/addGoodsModelVal',
    method:'get',
    params:pojo
  })
}
